【Tips】建立OnPropertyChanged。其中的方法簽章若沒有寫入,則預設為呼叫的成員名稱


using System.ComponentModel;
using System.Runtime.CompilerServices;
public class MyDataContext : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    public void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        //Console.WriteLine($"MyDataContext:OnPropertyChanged__{propertyName}");
    }
}
#wpf






你可能感興趣的文章

ES6(let 與 const、Template Literals)

ES6(let 與 const、Template Literals)

React-[入門篇]-在JSX中加入inline style樣式 | 引入 external css 檔案

React-[入門篇]-在JSX中加入inline style樣式 | 引入 external css 檔案

剛進 Lab 的碩 0

剛進 Lab 的碩 0






留言討論